package com.jy.api.dao;

import com.jy.api.domain.ElectronicBill;
import com.jy.api.domain.ResELC;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import java.util.Date;
import java.util.List;


/**
 * Created by lihu on 2017/12/20.
 */
public interface ElectronicBillDao extends CrudRepository<ElectronicBill, String> {


    Page<ElectronicBill> findByStoreIdAndDateBetween(String storeId,Date from,Date to, Pageable pageable);


    ElectronicBill findByStoreIdAndDate(String storeId,String date);


    @Query(value = "SELECT SUM(`service_charge_amount`)AS serviceChargeAmount,SUM(`total_amount_income`) AS totalAmount, SUM(`refund_amount`) AS refundAmount, sum(`total_singular`) AS totalSingular FROM `electronic_bill` WHERE `store_id` =? AND `date` >=? AND `date` <=?", nativeQuery = true)
    List<Object[]> findTotalByStoreId(String storeId, Date from, Date to);

}
